import {boot} from 'quasar/wrappers'
import cloudbase from "@cloudbase/js-sdk"

const cloud = cloudbase.init({
  env: process.env.envid,
});

// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
export default boot(async ({app}) => {
  // something to do
  console.log('init weixin', process.env.envid)
  const auth = cloud.auth();

  // 匿名登录
  await auth.anonymousAuthProvider().signIn()
    .then(() => {
      console.log('login in by anonymous')
      auth.getLoginState().then((loginState) => {
        console.log('login state:', loginState)
      });
      app.config.globalProperties.$cloud = cloud
    }).catch((e) => {
      console.log('login error', e)
    })

})

export {cloud}
